home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / fips11.zip / SOURCE / FIPSSPEC.CPP < prev    next >
C/C++ Source or Header  |  1994-05-25  |  4KB  |  116 lines

  1. /*
  2.     FIPS - the First nondestructive Interactive Partition Splitting program
  3.  
  4.     Module fipsspec.cpp
  5.  
  6.     RCS - Header:
  7.     $Header: c:/daten/fips/source/main/RCS/fipsspec.cpp 1.1 1994/05/25 22:19:55 schaefer Exp schaefer $
  8.  
  9.     Copyright (C) 1993 Arno Schaefer
  10.  
  11.     This program is free software; you can redistribute it and/or modify
  12.     it under the terms of the GNU General Public License as published by
  13.     the Free Software Foundation; either version 2 of the License, or
  14.     (at your option) any later version.
  15.  
  16.     This program is distributed in the hope that it will be useful,
  17.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.     GNU General Public License for more details.
  20.  
  21.     You should have received a copy of the GNU General Public License
  22.     along with this program; if not, write to the Free Software
  23.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25.  
  26.     Report problems and direct all questions to:
  27.  
  28.     schaefer@rbg.informatik.th-darmstadt.de
  29. */
  30.  
  31. #include "fipsspec.h"
  32. #include "global.h"
  33. #include <dos.h>
  34.  
  35. #define DISK_INT 0x13
  36.  
  37. #define RESET_DISK 0
  38. #define GET_DRIVE_PARAMS 8
  39.  
  40. void fips_bpb::print (void)
  41. {
  42.     printx ("Bytes per sector: %u\n",bytes_per_sector);
  43.     printx ("Sectors per cluster: %u\n",sectors_per_cluster);
  44.     printx ("Reserved sectors: %u\n",reserved_sectors);
  45.     printx ("Number of FATs: %u\n",no_of_fats);
  46.     printx ("Number of rootdirectory entries: %u\n",no_of_rootdir_entries);
  47.     printx ("Number of sectors (short): %u\n",no_of_sectors);
  48.     printx ("Media descriptor byte: %02Xh\n",media_descriptor);
  49.     printx ("Sectors per FAT: %u\n",sectors_per_fat);
  50.     printx ("Sectors per track: %u\n",sectors_per_track);
  51.     printx ("Drive heads: %u\n",drive_heads);
  52.     printx ("Hidden sectors: %lu\n",hidden_sectors);
  53.     printx ("Number of sectors (long): %lu\n",no_of_sectors_long);
  54.     printx ("Physical drive number: %02Xh\n",phys_drive_no);
  55.     printx ("Signature: %02Xh\n\n",signature);
  56. }
  57.  
  58. void fips_partition_table::print (void)
  59. {
  60.     printx ("     |        |     Start      |      |      End       | Start  |Number of|\n");
  61.     printx ("Part.|bootable|Head Cyl. Sector|System|Head Cyl. Sector| Sector |Sectors  |  MB\n");
  62.     printx ("-----+--------+----------------+------+----------------+--------+---------+----\n");
  63.     for (int i=0;i<4;i++)
  64.     {
  65.         printx ("%u    |    %s |%4u %4u   %4u|   %02Xh|%4u %4u   %4u|%8lu| %8lu|%4lu\n",i+1,
  66.         partition_info[i].bootable ? "yes" : " no",
  67.         partition_info[i].start_head,partition_info[i].start_cylinder,partition_info[i].start_sector,
  68.         partition_info[i].system,partition_info[i].end_head,partition_info[i].end_cylinder,partition_info[i].end_sector,
  69.         partition_info[i].start_sector_abs,partition_info[i].no_of_sectors_abs,partition_info[i].no_of_sectors_abs / 2048);
  70.     }
  71. }
  72.  
  73. void fips_harddrive::get_geometry (void)
  74. {
  75.     union REGS regs;
  76.  
  77.     regs.h.ah = GET_DRIVE_PARAMS;
  78.     regs.h.dl = number;
  79.     int86 (DISK_INT,®s,®s);
  80.     if (global.debug_mode)
  81.     {
  82.         fprintf (global.debugfile,"\nRegisters after call to int 13h 08h (drive %02Xh):\n\n",number);
  83.         hexwrite ((byte *) ®s,16,global.debugfile);
  84.     }
  85.     if ((errorcode = regs.h.ah) != 0) return;
  86.     geometry.heads = (dword) regs.h.dh + 1;
  87.     geometry.sectors = (dword) regs.h.cl & 0x3f;
  88.     geometry.cylinders = ((dword) regs.h.ch | (((dword) regs.h.cl << 2) & 0x300)) + 1;
  89. }
  90.  
  91. void fips_harddrive::reset (void)
  92. {
  93.     union REGS regs;
  94.  
  95.     regs.h.ah = RESET_DISK;
  96.     regs.h.dl = number;
  97.     int86 (DISK_INT,®s,®s);
  98.     if (global.debug_mode)
  99.     {
  100.         fprintf (global.debugfile,"\nRegisters after call to int 13h 00h (drive %02Xh):\n\n",number);
  101.         hexwrite ((byte *) ®s,16,global.debugfile);
  102.     }
  103.     errorcode = regs.h.ah;
  104. }
  105.  
  106. void fips_logdrive_info::put_debug_info (void)
  107. {
  108.     fprintf (global.debugfile,"Calculated Partition Characteristica:\n\n");
  109.     fprintf (global.debugfile,"Start of FAT 1: %lu\n",start_fat1);
  110.     fprintf (global.debugfile,"Start of FAT 2: %lu\n",start_fat2);
  111.     fprintf (global.debugfile,"Start of Rootdirectory: %lu\n",start_rootdir);
  112.     fprintf (global.debugfile,"Start of Data: %lu\n",start_data);
  113.     fprintf (global.debugfile,"Number of Clusters: %lu\n",no_of_clusters);
  114. }
  115.  
  116.